package com.example.base.net

import android.content.Context
import androidx.room.Room
import com.example.base.room.AppDataBase
import com.example.base.room.DateDao
import com.example.base.room.UserDao
import com.example.base.room.VideoDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object ProvideFactory {


    @Provides
    @Singleton
    fun getApiService():ApiService = RetrofitUtils.getInstance().retrofit.create(ApiService::class.java)

    @Provides
    @Singleton
    fun getShopApiService():ShopApiService = RetrofitUtils.getInstance().shopRetrofit.create(ShopApiService::class.java)
    @Provides
    @Singleton
    fun getVideoApiService():VideoApiService = RetrofitUtils.getInstance().videoRetrofit.create(VideoApiService::class.java)

    @Provides
    @Singleton
    fun initDataBase(@ApplicationContext context: Context):AppDataBase = Room.databaseBuilder(context,AppDataBase::class.java,"2306.db")
        .allowMainThreadQueries().build()

    //暴露userDao方法
    @Provides
    @Singleton
    fun userDao(appDataBase: AppDataBase):UserDao = appDataBase.getUserDao()

    @Provides
    @Singleton
    fun dateDao(appDataBase: AppDataBase):DateDao = appDataBase.getDateDao()
    @Provides
    @Singleton
    fun videoDao(appDataBase: AppDataBase):VideoDao = appDataBase.getVideoDao()




}